package com.eqs.enterprisequestionnaire.controller;

import com.eqs.enterprisequestionnaire.result.R;
import com.eqs.enterprisequestionnaire.service.DifferenceLevelQuestionAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/differenceLevelAnalysis")
public class DifferenceLevelQuestionAnalysisController {
    @Autowired
    private DifferenceLevelQuestionAnalysisService differenceLevelQuestionAnalysisService;

    @GetMapping("/gender1/{questionId}")
    public R<Map<Boolean, Double>> getGenderDifference(@PathVariable Integer questionId) {
        Map<Boolean, Double> result = differenceLevelQuestionAnalysisService.getGenderDifference(questionId);
        return R.success(result);
    }

    @GetMapping("/age1/{questionId}")
    public R<Map<String, Double>> getAgeDifference(@PathVariable Integer questionId) {
        Map<String, Double> result = differenceLevelQuestionAnalysisService.getAgeDifference(questionId);
        return R.success(result);
    }

    @GetMapping("/enterprise1/{questionId}")
    public R<Map<String, Double>> getEnterpriseDifference(@PathVariable Integer questionId) {
        Map<String, Double> result = differenceLevelQuestionAnalysisService.getEnterpriseDifference(questionId);
        return R.success(result);
    }

    @GetMapping("/role1/{questionId}")
    public R<Map<String, Double>> getRoleDifference(@PathVariable Integer questionId) {
        Map<String, Double> result = differenceLevelQuestionAnalysisService.getRoleDifference(questionId);
        return R.success(result);
    }

    @GetMapping("/gender2/{questionId}")
    public R<Map<Boolean, Map<Integer, Double>>> getGenderLevelProportions(@PathVariable Integer questionId) {
        Map<Boolean, Map<Integer, Double>> result = differenceLevelQuestionAnalysisService.getGenderLevelProportions(questionId);
        return R.success(result);
    }

    @GetMapping("/enterprise2/{questionId}")
    public R<Map<String, Map<Integer, Double>>> getEnterpriseLevelProportions(@PathVariable Integer questionId) {
        Map<String, Map<Integer, Double>> result = differenceLevelQuestionAnalysisService.getEnterpriseLevelProportions(questionId);
        return R.success(result);
    }

    @GetMapping("/role2/{questionId}")
    public R<Map<String, Map<Integer, Double>>> getRoleLevelProportions(@PathVariable Integer questionId) {
        Map<String, Map<Integer, Double>> result = differenceLevelQuestionAnalysisService.getRoleLevelProportions(questionId);
        return R.success(result);
    }

    @GetMapping("/age2/{questionId}")
    public R<Map<String, Map<Integer, Double>>> getAgeLevelProportions(@PathVariable Integer questionId) {
        Map<String, Map<Integer, Double>> result = differenceLevelQuestionAnalysisService.getAgeLevelProportions(questionId);
        return R.success(result);
    }
}
